<?php

namespace App\Models\VoteCandidate;

use App\Models\Activity\Activity;
use App\Models\Groupable;
use App\Models\Resource\Resource;
use App\Models\VoteGroup\VoteGroup;
use App\Support\Database\Eloquent\UuidModel;

class VoteCandidate extends UuidModel
{
    protected $fillable = [
        'group_id',
        'activity_id',
        'order_id',
        'description',
        'title',
        'type',
        'cover_url',
        'resource_url',
        'resource_id',
        'content',
        'votes_number',
        'id',
        'weight',
        'status',
        'code',
        'from',
    ];
    const TYPE_IMAGE = 1;
    const TYPE_AUDIO = 2;
    const TYPE_VIDEO = 3;
    const TYPE_URL = 4;
    const SHELVES_ON = 0;
    const SHELVES_OFF = 1;
    protected $dates = ['delete_at'];


    public function voteGroup()
    {
        return $this->belongsTo(VoteGroup::class, 'group_id', 'id');
    }

    public function activity()
    {
        return $this->belongsTo(Activity::class, 'activity_id', 'id');
    }

	/*
	public function resource()
	{
		return $this->hasMany(Resource::class, 'candidate_id', 'id');
	}
	*/

	public function resource()
    {
        return $this->hasOne(Resource::class, 'resource_id', 'resource_id');
    }
}
